package org.apitool.main;

import java.io.Serializable;

public class PostParameter  implements Serializable,Comparable<PostParameter>
{
	private static final long serialVersionUID = -8133293435983878308L;
	
	String name;
	String value;
	
	PostParameter(String name, String value)
	{
		this.name = name;
		this.value = value;
	}
	
	public PostParameter(String name, double value) 
	{
        this.name = name;
        this.value = String.valueOf(value);
    }
	
	public PostParameter(String name, long value) 
	{
        this.name = name;
        this.value = String.valueOf(value);
    }

    public PostParameter(String name, int value) 
    {
        this.name = name;
        this.value = String.valueOf(value);
    }
    
    public int hashCode() 
    {
        int result = name.hashCode();
        return  31 * result + value.hashCode();
    }

     public boolean equals(Object obj) 
     {
        if (null == obj) 
        {
            return false;
        }
        
        if (this == obj)
        {
            return true;
        }
        
        if (obj instanceof PostParameter) 
        {
            PostParameter that = (PostParameter) obj;
            return this.name.equals(that.name) &&
                this.value.equals(that.value);
        }
        
        return false;
    }

	@Override
	public int compareTo(PostParameter another) 
	{
		int compared = name.compareTo(another.name);
        if (0 == compared) 
        {
            compared = value.compareTo(another.value);
        }
        return compared;
	}
}
